package cn.edu.sdjzu.knoverse.model.entity.kg;

import cn.edu.sdjzu.knoverse.config.IdGenerator;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Property;

import java.time.LocalDateTime;

@Data
public class BaseNode {

    /**
     * 主键id，使用雪花算法生成
     */
    @Id
    @Property("nodeId")
    @JsonProperty("nodeId")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long nodeId = IdGenerator.nextId();

    /**
     * 节点名称
     */
    @Property("name")
    private String name;

    /**
     * 节点描述
     */
    @Property("description")
    private String description;

    /**
     * 颜色
     */
    @Property("color")
    private String color;

    /**
     * 大小
     */
    @Property("size")
    private Integer size;

    /**
     * 创建时间
     */
    @CreatedDate
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    private LocalDateTime updateTime;

    /**
     * 创建人id
     */
    @Property("createById")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long createdById;

    /**
     * 创建人username
     */
    @Property("createByUsername")
    private String createdByUsername;

    /**
     * 更新人id
     */
    @Property("updateById")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Long updatedById;

    /**
     * 更新人username
     */
    @Property("updateByUsername")
    private String updatedByUsername;
}
